﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace MobileTipper
{
    public static class Tip
    {
        public static decimal AmountOfBill { get; set; }

        public static decimal TaxRate { get; set; }

        public static decimal AmountOfSubtotal { get; set; }

        public static decimal TipRate { get; set; }

        public static int NumberInParty { get; set; }

        public static decimal AmountOfTotal { get; set; }

        public static decimal AmountOfTax { get; set; }

        public static decimal AmountOfTip { get; set; }

        public static decimal IndividualShare { get; set; }

        public static void Test()
        {
            AmountOfBill = 100.00M;
            TaxRate = 6.00M;
            TipRate = 15.00M;
            NumberInParty = 4;
        }

        public static void Clear()
        {
            AmountOfBill = 0M;
            TaxRate = 0M;
            AmountOfSubtotal = 0M;
            TipRate = 0M;
            NumberInParty = 1;
            AmountOfTotal = 0M;
            AmountOfTip = 0M;
            IndividualShare = 0M;
        }

        public static void Calculate()
        {
            AmountOfTax = Math.Round(AmountOfBill * TaxRate / 100, 2);
            AmountOfSubtotal = AmountOfBill + AmountOfTax;

            AmountOfTip = Math.Round(AmountOfSubtotal * TipRate / 100, 2);
            IndividualShare = Math.Round(AmountOfTip / NumberInParty, 2);

            AmountOfTotal = AmountOfSubtotal + IndividualShare * NumberInParty;
        }
    }
}
